#!/bin/bash
bazel build --java_language_version=21 --tool_java_language_version=21 --java_runtime_version=remotejdk_21  java/com/google/copybara:generate_reference
mkdir -p docs
cp bazel-bin/java/com/google/copybara/reference.md docs/reference.md
git add docs/reference.md
# If -a we ammend the current head commit
if [[  $1 == '-a' ]]; then
    echo "Ammending current commit ($(git rev-parse HEAD))"
    git commit docs/reference.md --amend -C HEAD
else
    echo "Creating a new commit"
    git commit docs/reference.md -m "Update reference documentation to latest version"
fi
